﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace iNet.Win32
{
	/// <summary>
	/// 提供 Kernel32.dll 的 Windows API 函式。
	/// </summary>
	public static unsafe class Kernel32
	{
		#region AddDllDirectory
		[DllImport("Kernel32", SetLastError = true)]
		public static extern IntPtr AddDllDirectory(string NewDirectory);
		#endregion
		#region CloseHandle
		[DllImport("Kernel32", SetLastError = true)]
		public static extern bool CloseHandle(IntPtr hObject);
		#endregion
		#region CopyMemory
		[DllImport("Kernel32")]
		public static extern void CopyMemory(void* Destination, void* Source, int Length);
		[DllImport("Kernel32")]
		public static extern void CopyMemory(IntPtr Destination, IntPtr Source, int Length);
		[DllImport("Kernel32")]
		public static extern void CopyMemory(void* Destination, void* Source, uint Length);
		[DllImport("Kernel32")]
		public static extern void CopyMemory(IntPtr Destination, IntPtr Source, uint Length);
		#endregion
		#region CreateFile
		[DllImport("Kernel32", SetLastError = true)]
		public static extern IntPtr CreateFile(string lpFileName, GENERIC dwDesiredAccess, FILE_SHARE dwShareMode, IntPtr lpSecurityAttributes, FileCreationDisposition dwCreationDisposition, FILE dwFlagsAndAttributes, IntPtr hTemplateFile);
		#endregion
		#region FillMemory
		[DllImport("Kernel32")]
		public static extern void FillMemory(IntPtr Destination, int Length, byte Fill);
		[DllImport("Kernel32")]
		public static extern void FillMemory(IntPtr Destination, uint Length, byte Fill);
		[DllImport("Kernel32")]
		public static extern void FillMemory(void* Destination, int Length, byte Fill);
		[DllImport("Kernel32")]
		public static extern void FillMemory(void* Destination, uint Length, byte Fill);
		#endregion
		#region RemoveDllDirectory
		[DllImport("Kernel32", SetLastError = true)]
		public static extern bool RemoveDllDirectory(IntPtr Cookie);
		#endregion
		#region SetDllDirectory
		[DllImport("Kernel32", SetLastError = true)]
		public static extern bool SetDllDirectory(string lpPathName);
		#endregion
	}
}
